#include "GtPro.h"
#include "GtMsg.h"
#include "GtUdp.h"
#include "GtUtl.h"
#include "GtAcbm.h"
#include "GtConf.h"
#include "GtTime.h"
#include "GtTmap.h"

#include "GtDcpDef.h"
#include "GtHash.h"

#include <getopt.h>
#include <signal.h>
#include <bitset>
#include <iostream>
#include <netinet/ip.h>
#define	__FAVOR_BSD
#include <netinet/tcp.h>

using namespace GtCls;
using namespace GtIpc;

typedef struct _GtDhStrEnd_t{
	GTDCPSHMBASE_S	start;
	GTDCPSHMBASE_S	end;
}GtDhStrEnd_t;


static GTDCPSHMDEVS_S* 	gpstHttp;
static GtIpc::CGtShm	RecvShmHttp;


typedef std::string CSTRING;
typedef CGtMap<CSTRING, UINT, GTMAPSTRING_O> 	GTDHSHM_MAP;

int main()
{
	if (GT_SUCCESS == RecvShmHttp.GtIpcCreate(RecvShmHttp.GtIpcKey(GT_DD_CTRL, GT_DD_KDNS), GT_DD_CTTL * sizeof(GTDCPSHMDEVS_S))) {
		gpstHttp = (GTDCPSHMDEVS_S*)RecvShmHttp.GtShmGetShm();
	}else{
		GT_PRINT("Failed to HTTP GtShmGet\n");
		return GT_FAILURE;
	}
	
	GTDCPSHMDEVS_S* count = (GTDCPSHMDEVS_S*)gpstHttp;
	

	GT_PRINT("net:%s\npid:%s\nRecvPkt:%lld\nRecvByte:%lld\nSndPkt:%lld\nSndByte:%lld\n"
			 "PktErrs:%lld\nPktErrsByte:%lld\nParseErrs:%lld\nParseErrsByte:%lld\n"
			 "DrpPkt:%lld\nDrpByte:%lld\nQueErrs:%lld\n",
			 count->m_stInfo.m_szDev, count->m_stInfo.m_szPid,
			 count->m_stBase.m_ullRcvPkts,
			 count->m_stBase.m_ullRcvByte,
			 count->m_stBase.m_ullSndPkts,
			 count->m_stBase.m_ullSndByte,
			 count->m_stBase.m_ullPktErrs,
			 count->m_stBase.m_ullPktErrsByte,
			 count->m_stBase.m_ullParseErrs,
			 count->m_stBase.m_ullParseErrsByte,
			 count->m_stBase.m_ullDrpPkts,
			 count->m_stBase.m_ullDrpByte,
			 count->m_stBase.m_ullQueErrs);
	
	return 0;
}
